def is_valid_sequence(sequence):
    while "()" in sequence or "[]" in sequence or "{}" in sequence or "<>" in sequence:
        sequence = sequence.replace("()", "").replace("[]", "").replace("{}", "").replace("<>", "")
    return not sequence
a = input("Введите скобочную последовательность: ")
print(is_valid_sequence(a))
